package org.rc.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import org.rc.dto.DczUpdateDto;
import org.rc.dto.UserAddDto;
import org.rc.dto.UserUpdateDto;

import java.time.LocalDateTime;


@Data
public class User {
    @TableId(value = "id",type = IdType.AUTO)
    private Long id;

    private String name;

    private String loginName;

    private Integer gender;

    private String phoneNo;

    private String post;

    private String pwd;

    private Integer isAdmin;

    private Integer isDeleted;

    private Integer isDcz;

    private LocalDateTime createdTime;


    public static User getInstance(UserAddDto userAddDto){
        User user = new User();
        user.setName(userAddDto.getName());
        user.setGender(userAddDto.getGender());
        user.setPhoneNo(userAddDto.getPhoneNo());
        user.setPost(userAddDto.getPost());
        user.setLoginName(userAddDto.getLoginName());
        user.setCreatedTime(LocalDateTime.now());
        return user;
    }

    public static User getInstance(UserUpdateDto userUpdateDto){
        User user = new User();
        user.setName(userUpdateDto.getName());
        user.setGender(userUpdateDto.getGender());
        user.setPhoneNo(userUpdateDto.getPhoneNo());
        user.setPost(userUpdateDto.getPost());
        user.setLoginName(userUpdateDto.getLoginName());
        return user;
    }

    public static User getInstance(DczUpdateDto dczUpdateDto){
        User user = new User();
        user.setId(dczUpdateDto.getId());
        user.setName(dczUpdateDto.getName());
        user.setLoginName(dczUpdateDto.getLoginName());
        return user;
    }
}
